﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using CanDoo.Core.Data;
using CanDoo.Data;
using CanDoo.Admin.Core.Models;
using System.ComponentModel.DataAnnotations.Schema;

namespace CanDoo.Oil.Core.Models
{
    /// <summary>
    /// 状态
    /// </summary>
    public enum OilSerialStatus
    {
        //0等待审核入库 1审核入库 2等待审核出库 3审核出库 4等待客户退货审核 5客户退货 6申请更换油桶 7上机销售 8售罄
        /// <summary>
        /// 0等待审核入库
        /// </summary>
        [Display(Name = "等待审核入库")]
        WaitIn,
        /// <summary>
        /// 1审核入库
        /// </summary>
        [Display(Name = "审核入库")]
        PassIn,
        /// <summary>
        /// 2等待审核采购退货
        /// </summary>
        [Display(Name = "等待审核采购退货")]
        WaitBuyBack,
        /// <summary>
        /// 3审核采购退货
        /// </summary>
        [Display(Name = "审核采购退货")]
        BuyBack,
        /// <summary>
        /// 4等待审核出库
        /// </summary>
        [Display(Name = "等待审核出库")]
        WaitOut,
        /// <summary>
        /// 5审核出库
        /// </summary>
        [Display(Name = "审核出库")]
        PassOut,
        /// <summary>
        /// 6等待客户退货审核
        /// </summary>
        [Display(Name = "等待客户退货审核")]
        WaitBack,
        /// <summary>
        /// 7客户退货
        /// </summary>
        [Display(Name = "客户退货")]
        Back,
        /// <summary>
        /// 8申请更换油桶
        /// </summary>
        [Display(Name = "申请更换油桶")]
        RequestChange,
        /// <summary>
        /// 9上机销售
        /// </summary>
        [Display(Name = "上机销售")]
        OnSale,
        /// <summary>
        /// 10售罄
        /// </summary>
        [Display(Name = "售罄")]
        SaleOut,
    }

    /// <summary>
    /// 实体类——油品序列号
    /// </summary>
    [Serializable]
    [Description("油品序列号")]
    public class OilSerialNum :  EntityBase,ICreatedTime, IAudited
    {
        /// <summary>
        /// 入库说明
        /// </summary>
        [Display(Name = "入库说明")]
        public override string Name { get; set; }

        /// <summary>
        /// 出库说明
        /// </summary>
        [Display(Name = "出库说明")]
        public string OutName { get; set; }

        /// <summary>
        /// 出库说明
        /// </summary>
        [Display(Name = "采购退货说明")]
        public string BuyBackName { get; set; }

        /// <summary>
        /// 出库说明
        /// </summary>
        [Display(Name = "销售退货说明")]
        public string SellBackName { get; set; }

        /// <summary>
        ///入库方式
        /// </summary>
        [Display(Name = "入库方式")]
        public virtual InStoreType InStoreType { get; set; }
        /// <summary>
        ///入库方式外键
        /// </summary>
        [Display(Name = "入库方式外键")]
        public long InStoreTypeId { get; set; }

        /// <summary>
        ///入库单号
        /// </summary>
        [Display(Name = "入库单号")]
        [Required]
        public long InStoreId { get; set; }

        /// <summary>
        ///采购退货单
        /// </summary>
        [Display(Name = "采购退货单")]
        public virtual InBuyBack InBuyBack { get; set; }
        /// <summary>
        ///采购退货单外键
        /// </summary>
        [Display(Name = "采购退货单外键")]
        public long? InBuyBackId { get; set; }

        /// <summary>
        ///出库方式
        /// </summary>
        [Display(Name = "出库方式")]
        public virtual OutStoreType OutStoreType { get; set; }
        /// <summary>
        ///出库方式外键
        /// </summary>
        [Display(Name = "出库方式外键")]
        public long? OutStoreTypeId { get; set; }

        /// <summary>
        ///出库单号
        /// </summary>
        [Display(Name = "出库单号")]
        public long? OutStoreId { get; set; }

        /// <summary>
        ///销售退货单
        /// </summary>
        [Display(Name = "销售退货单")]
        public virtual OutSellBack OutSellBack { get; set; }
        /// <summary>
        ///销售退货单外键
        /// </summary>
        [Display(Name = "销售退货单外键")]
        public long? OutSellBackId { get; set; }

        /// <summary>
        ///仓库
        /// </summary>
        [Display(Name = "仓库")]
        public virtual Warehouse Warehouse { get; set; }
        /// <summary>
        ///仓库外键
        /// </summary>
        [Display(Name = "仓库外键")]
        public long WarehouseId { get; set; }

        /// <summary>
        ///产品
        /// </summary>
        [Display(Name = "产品")]
        public virtual Product Product { get; set; }
        /// <summary>
        ///产品外键
        /// </summary>
        [Display(Name = "产品外键")]
        public long ProductId { get; set; }

        /// <summary>
        ///序列号
        /// </summary>
        [Display(Name = "序列号")]
        [Required, StringLength(50)]
        [Index(IsUnique = true)]
        public string SerialNumber { get; set; }

        /// <summary>
        ///服务中心客户
        /// </summary>
        [Display(Name = "服务中心客户")]
        public virtual Customer ServiceCenter { get; set; }
        /// <summary>
        ///服务中心客户外键
        /// </summary>
        [Display(Name = "服务中心客户外键")]
        public long? ServiceCenterId { get; set; }

        /// <summary>
        ///终端客户
        /// </summary>
        [Display(Name = "终端客户")]
        public virtual Customer Customer { get; set; }
        /// <summary>
        ///终端客户外键
        /// </summary>
        [Display(Name = "终端客户外键")]
        public long? CustomerId { get; set; }

        /// <summary>
        ///售油机
        /// </summary>
        [Display(Name = "售油机")]
        public virtual OilSalesSerialNum OilSalesSerialNum { get; set; }
        /// <summary>
        ///售油机外键
        /// </summary>
        [Display(Name = "售油机外键")]
        public long? OilSalesSerialNumId { get; set; }

        /// <summary>
        ///出油口
        /// </summary>
        [Display(Name = "出油口")]
        [Range(0,3,ErrorMessage = "出油口编号只能是1 - 3")]
        public int OilPort { get; set; }

        /// <summary>
        ///上机日期
        /// </summary>
        [Display(Name = "上机日期")]
        public DateTime? UpTime { get; set; }

        /// <summary>
        ///剩余油量
        /// </summary>
        [Display(Name = "剩余油量")]
        public double LastOil { get; set; }

        /// <summary>
        ///下机日期
        /// </summary>
        [Display(Name = "下机日期")]
        public DateTime? DownTime { get; set; }

        /// <summary>
        ///生产日期
        /// </summary>
        [Display(Name = "生产日期")]
        public DateTime? BirthDay { get; set; }

        /// <summary>
        ///生产批次
        /// </summary>
        [Display(Name = "生产批次")]
        [StringLength(50)]
        public string Batch { get; set; }

        /// <summary>
        ///过期日期
        /// </summary>
        [Display(Name = "过期日期")]
        public DateTime? OverdueDay { get; set; }

        /// <summary>
        /// 状态 0等待审核入库 1审核入库 2等待审核采购退货 3审核采购退货 4等待审核出库 5审核出库 6等待客户退货审核 7客户退货 8申请更换油桶 9上机销售 10售罄
        /// </summary>
        [Display(Name = "状态")]
        public OilSerialStatus Status { get; set; }
        #region Implementation of ICreatedTime

        /// <summary>
        /// 获取设置 信息创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        #region Implementation of ICreatedAudited

        /// <summary>
        /// 获取或设置 创建者编号
        /// </summary>
        [Display(Name = "创建人")]
        public string CreatorUserId { get; set; }

        #endregion

        #region Implementation of IUpdateAutited

        /// <summary>
        /// 获取或设置 最后更新时间
        /// </summary>
        [Display(Name = "最后更新时间")]
        public DateTime? LastUpdatedTime { get; set; }

        /// <summary>
        /// 获取或设置 最后更新者编号
        /// </summary>
        [Display(Name = "最后更新用户")]
        public string LastUpdatorUserId { get; set; }

        #endregion
    }

}
